package com.jiazhong.集合类.Collection.Set.TreeSet;

public class User implements Comparable<User>{

    private Integer userId;
    private String username;
    private String password;

    public User(){}

    public User(Integer userId, String username, String password) {
        this.userId = userId;
        this.username = username;
        this.password = password;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    /**
     * 比较器的比较方法
     * @param user
     * @return    大于0:当前对象大于user对象
     *            等于0:两个对象相等
     *            小于0:当前对象小于user对象
     */
    @Override
    public int compareTo(User user) {
        return user.userId-this.userId;
    }
}
